import torch


def selection_tournament_faster(self, tourn_size=3):
    '''
    Select the best individual among *tournsize* randomly chosen
    Same with `selection_tournament` but much faster using numpy
    individuals,
    :param self:
    :param tourn_size:
    :return:
    '''
    aspirants_idx = torch.randint(self.size_pop, size=(self.size_pop, tourn_size), device=self.device)
    aspirants_values = self.FitV[aspirants_idx]

    winner_mask = aspirants_values == torch.max(aspirants_values, dim=1).values.view(-1, 1)
    winner_mask = winner_mask * torch.arange(1, tourn_size + 1, device=self.device)
    winner_mask = winner_mask == torch.max(winner_mask, dim=1).values.view(-1, 1)

    # winner index in every team
    sel_index = torch.max(aspirants_idx * winner_mask, dim=1).values

    self.Chrom = self.Chrom[sel_index]
    return self.Chrom
